import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set_node_cls from "@dfeidao/atom-web/ui/set-node-cls";
import set from '@dfeidao/atom-web/local/set';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';

import p001 from './p001';
import p002 from './p002';
import p003 from './p003';

export default async function a001(fd: IFeidaoAiBrowserComponent, flag: string) {


	// 显示隐患元添加弹出框
	const d = fd.data.node.querySelector<HTMLDivElement>('[data-name="yhadd"]');
	set_node_cls(d, 'display-n', false);

	const pn = fd.data.params['page-no'] as string;
	let pno = 1;
	if (pn) {
		pno = parseInt(pn, 10);
	}

	set(fd, 'flag', flag);

	console.log("那个隐患元==》", flag);


	console.log(pno);
	// todo

	const res = await nodejs<{ res: Array<{}>; c: number; }>('risk_point/zj-000005/s001', {
		hidden_name: '', hidden_source: '', page_no: 1
	});
	console.info("lllllllllllllllll", res);
	if (res.res.length > 1) {
		render(fd, res.res, p001, 'p001', 'inner');
		render(fd, { page_no: 1, total: res.c }, p002, 'p002', 'inner');
	} else {
		render(fd, '', p003, 'p003', 'inner');
	}






}
